import 'package:flutter/material.dart';
import 'package:osc/res/colors.dart';
import 'package:osc/res/dimens.dart';
import 'package:osc/utils/string_util.dart';

class CommonListSelectDialogWidget extends StatelessWidget {
  final String title;
  final Widget listView;

  CommonListSelectDialogWidget(
      {
        this.title,
        @required this.listView,
        Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return new Padding(
      padding: EdgeInsets.all(Dimens.gap_activity_horizontal),
      child: new Material(
        type: MaterialType.transparency,
        child: new Center(
         child: Container(
           decoration: ShapeDecoration(
             color: Colors.white,
             shape: RoundedRectangleBorder(
               borderRadius: BorderRadius.all(
                 Radius.circular(Dimens.gap_view_big),
               ),
             ),
           ),
           margin: EdgeInsets.all(Dimens.gap_view_big),
           child: new ListView(
             shrinkWrap: true,
             children: <Widget>[
               new Padding(
                 padding: const EdgeInsets.all(Dimens.gap_view_normal),
                 child: new Stack(
                   alignment: AlignmentDirectional.centerEnd,
                   children: <Widget>[
                     new Center(
                       child: new Text(
                         StringUtil.isEmpty(title)?"":title,
                         style: new TextStyle(
                           fontSize: Dimens.font_sp18,
                         ),
                       ),
                     ),
                     new GestureDetector(
                       onTap: (){
                         Navigator.pop(context);
                       },
                       child: new Padding(
                         padding: EdgeInsets.all(Dimens.gap_view_small),
                         child: new Icon(
                           Icons.close,
                           color: Colors.black54,
                         ),
                       ),
                     ),
                   ],
                 ),
               ),
               new Divider(
                 color: Colours.divider,
                 height: StringUtil.isEmpty(title)?0:Dimens.gap_divider_height_smallest,
               ),
               listView,
             ],
           ),
         ),
        ),
      ),
    );
  }
}